<template>
  <div class="page-home">
    <div class="home-entry">
      <div class="container">
        <!-- 左侧分类 -->
        <HomeCategory />
        <!-- banner轮播图 -->
        <HomeBanner />
        <!-- 楼层模块 新鲜好物-->
        <!-- 🔔Vue3 新特性：Suspense 组件
        1. 可配合异步组件使用，加载的 loading 效果可以放 #fallback 插槽中
        2. 被 Suspense 默认插槽包裹的组件，可以用 async setup ( setup 返回 Promise 能被处理 ) -->
        <Suspense>
          <HomeNew />
        </Suspense>
        <!-- 楼层模块 人气推荐 -->
        <Suspense>
          <template #default>
            <HomeHot />
          </template>
          <template #fallback>
            <div>异步组件加载中... Loading...</div>
          </template>
        </Suspense>
      </div>
    </div>
  </div>
</template>

<script>
import HomeCategory from './components/home-category.vue'
import HomeBanner from './components/home-banner.vue'
import HomeNew from './components/home-new.vue'
// 定义异步组件的函数 defineAsyncComponent
import { defineAsyncComponent } from 'vue'
// import HomeHot from './components/home-hot.vue'

export default {
  name: 'PageHome',
  components: {
    HomeBanner,
    HomeCategory,
    HomeNew,
    HomeHot: defineAsyncComponent(() => import('./components/home-hot.vue'))
  }
}
</script>

<style scoped lang='less'>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>
